﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Exhibition.Common.Helper;
using System.Drawing;
using System.Messaging;
namespace Exhibition
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {






           // Response.Write("Host:" + Request.Url.Host + "<br/>");
           // Response.Write("Port:" + Request.Url.Port + "<br/>");
           // Response.Write("AbsolutePath:" + Request.Url.AbsolutePath + "<br/>");
           // Response.Write("AbsoluteUri:" + Request.Url.AbsoluteUri + "<br/>");
           // Response.Write("RawUrl:" + Request.RawUrl + "<br/>");
           // Response.Write("Path:" + Request.Path + "<br/>");
           // Response.Write("UrlReferrer" + Request.UrlReferrer + "<br/>");
           //// Response.Write("ServerVariables" + Request.ServerVariables + "<br/>");
           // Response.Write("PhysicalPath" + Request.PhysicalPath + "<br/>");
           // Response.Write("PhysicalApplicationPath" + Request.PhysicalApplicationPath + "<br/>");
          // CodeHelper cdl=new CodeHelper();
          //System.Drawing.Image img = cdl.EncodeBarcode(TextBox_39.Text.Trim(),300,200,true);
          //img1.ImageUrl = img;
        }

        protected void Button_39_Click(object sender, EventArgs e)
        {
            Literal_39.Text = CodeHelper.get39(TextBox_39.Text.Trim(), int.Parse(TextBox_39_w.Text.Trim()), int.Parse(TextBox_39_h.Text.Trim()));

        }

        protected void Button_EAN13_Click(object sender, EventArgs e)
        {
            Literal_EAN13.Text = CodeHelper.getEAN13(TextBox_EAN13.Text.Trim(), int.Parse(TextBox_EAN13_w.Text.Trim()), int.Parse(TextBox_EAN13_h.Text.Trim()));

        }

        protected void btn_Click(object sender, EventArgs e)
        {
            String queuename = @".\private$\new";

            if (!MessageQueue.Exists(queuename))
            {
                MessageQueue.Create(queuename);
            }

            MessageQueue que = new MessageQueue(queuename);
            Message message = new System.Messaging.Message(); 
            message.Body = txt.Text.Trim(); 
            que.Formatter = new BinaryMessageFormatter();
            que.Send(message);
            while (true)
            {
                using (Message msg = que.Peek())
                {
                    String str = (String)msg.Body;
                    rectxt.Text=str;
                   
                }
            }




        }

        private void btnReceiveMessage_Click(object sender, System.EventArgs e)
        {

          

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            // Open queue

            System.Messaging.MessageQueue queue = new System.Messaging.MessageQueue(".\\Private$\\new");



            // Receive message, 同步的Receive方法阻塞当前执行线程，直到一个message可以得到 

            System.Messaging.Message message = queue.Receive();

            message.Formatter = new System.Messaging.XmlMessageFormatter(new Type[] { typeof(string) });

            rectxt.Text = message.Body.ToString();
        }


    }
}